package com.xiyi.shouxin.entity.user.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.lang.Nullable;

import com.xiyi.shouxin.entity.user.User;

public class UserMapper implements RowMapper<User> {

    @Override
    @Nullable
    public User mapRow(@Nullable ResultSet rs, int rowNum) throws SQLException {
        User user = new User();
        if (rs == null) {
            return user;
        }
        user.setId(rs.getLong("id"));
        user.setAdminId(rs.getLong("adminId"));
        user.setDeviceId(rs.getString("device_id"));
        user.setAccount(rs.getString("account"));
        user.setNickName(rs.getString("nickname"));
        user.setRealName(rs.getString("realname"));
        user.setAvatar(rs.getString("avatar"));
        user.setSex(rs.getInt("sex"));
        user.setPhone(rs.getString("phone"));
        user.setStudentId(rs.getString("student_id"));
        user.setProvince(rs.getString("province"));
        user.setCity(rs.getString("city"));
        user.setArea(rs.getString("area"));
        user.setToken(rs.getString("token"));
        user.setOpenid(rs.getString("openid"));
        user.setSessionKey(rs.getString("session_key"));
        user.setIsBind(rs.getInt("is_bind"));
        user.setIsAnswer(rs.getInt("is_answer"));
        user.setCreatedAt(rs.getTimestamp("created_at"));
        user.setUpdatedAt(rs.getTimestamp("updated_at"));
        user.setDeletedAt(rs.getTimestamp("deleted_at"));
        user.setFeedback(rs.getString("feedback"));
        return user;
    }
}
